#!/usr/bin/env ipy.exe
#=00
#=01 hook in an assembly
import clr #01
clr.AddReference("System.Windows.Forms") #01
from System.Windows.Forms import *

#=02 event handlers
class MyForm(Form):
    def __init__(self):
        Form.__init__(self)
        self.Height = 100
        self.Width = 100
        showButton = Button()
        showButton.Text = "Click Me"
        showButton.Click += self.showDialog #02
        self.Controls.Add(showButton)
        quitButton = Button()
        quitButton.Text = "Quit"
        quitButton.Top = showButton.Height + 10
        quitButton.Click += self.quit #02
        self.Controls.Add(quitButton)
        self.Text = "Simple Form"
 
    def showDialog(self, f, a):
        MessageBox.Show("Hello World")

    def quit(self, f, a):
        Application.Exit()
        
#=03 running the example
f = MyForm() #03
Application.Run(f) #03
